<?php 

$conn = mysqli_connect('localhost','root','123456','test');

$query = mysqli_query($conn,'select * from users');

while ($row = mysqli_fetch_assoc($query)) {
	$data[] = $row;
}

// 一行代码搞定
//允许跨域请求

header('Access-Control-Allow-Origin: *');

header('Content-Type: application/json');
echo json_encode($data);













